# @Version  : 1.0
# @Author   : wgq
# @File     : main.py
# @Date     : 2025/6/10 19:57
from houseOperation import *
while True:
    printMenu()
    choice = input("请输入你的选择: ")
    if choice == "1":
        # print("增加房屋....")
        addHouse()
    elif choice == "2":
        # print("删除房屋...")
        if choice == -1:
            continue
        del_key = int(input("请输入要删除房屋的编号："))
        ret = findHouse(del_key)
        if ret == -1:
            print("该房屋信息不存在！")
            continue
        else:
            while True:
                choice = input("是否删除(是：Y|否：N)")
                if choice.lower() == 'y' or choice.lower() == 'n':
                    break
        if choice.lower() == 'n':
            break
        delHouse(del_key)
        print("删除成功！")

    elif choice == "3":
        # print("更改房屋...")
        update_key = int(input("请输入要更改房屋的编号："))
        ret = findHouse(update_key)
        if ret == -1:
            print("该房屋信息不存在！")
            continue
        updateHouse(update_key)
        print("更改成功！")

    elif choice == "4":
        # print("查找房屋...")
        find_key = int(input("请输入要查找房屋的编号："))
        find_id = findHouse(find_key)
        if find_id != -1:
            print(f"{find_key}编号房屋存在，具体信息如下：")
            print("编号\t\t房主\t\t电话\t\t地址\t\t租金\t\t状态")
            printHouse(find_id)
        else:
            print(f"{find_key}编号房屋不存在")
    elif choice == "5":
        # print("显示房屋列表...")
        listHouse()
    elif choice == "6":
        break
    else:
        print("输入有误，请重新输入")

print("退出系统，欢迎下次使用...")
